package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IAddCompletionOrderCommentView;
import com.cloudsigns.factorymanager2.engineering.model.AddCompletionOrderCommentModel;
import com.cloudsigns.factorymanager2.engineering.model.IAddCompletionOrderCommentModel;

/**
 * Created by tony on 2018/5/11.
 */

public class AddCompletionOrderCommentPresenter {
    private IAddCompletionOrderCommentView view;
    private IAddCompletionOrderCommentModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public AddCompletionOrderCommentPresenter(IAddCompletionOrderCommentView view) {
        this.view = view;
        this.model = new AddCompletionOrderCommentModel();
    }

    public void addCompletionOrderComment() {


        model.addCompletionOrderComment(view.getEvaluateInfo(), view.getOrderId(), new AddCompletionOrderCommentModel.OnAddCompletionOrderCommentListener() {
            @Override
            public void addCompletionOrderCommentSuccessed(final String id) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.addCompletionOrderCommentSuccessed(id);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void addCompletionOrderCommentFailed(final String desc) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.addCompletionOrderCommentFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });

    }
}
